package tms.model;

import java.util.Map;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Destination{

    public static final String TABLE_NAME = "Destination";
    public static String[] COLUMNS = {"DestName", "DestCode", "IsActive"};

    private int id = -1;
    private String destName = "";
    private String destCode = "";
    private boolean isActive = false;

    public String[] getValues() {
        return new String[] {"'" + getDestName() + "'", "'" + getDestCode() + "'",
                isActive() == true ? "1" : "0"};
    }

    static Destination createEntityFrom(Map<String, Object> map) {

        Destination entity = new Destination();

        entity.setId((Integer) map.get("Id".toLowerCase()));
        entity.setDestName((String) map.get("DestName".toLowerCase()));
        entity.setDestCode((String) map.get("DestCode".toLowerCase()));
        entity.setActive((Integer) map.get("IsActive".toLowerCase()) == 1);

        return entity;
    }

    public String toString() {
        return destName + " (" + destCode + ")";
    }

    /****************************************************************************/

    @XmlElement
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @XmlElement
    public String getDestName() {
        return destName;
    }

    public void setDestName(String destName) {
        this.destName = destName;
    }

    @XmlElement
    public String getDestCode() {
        return destCode;
    }

    public void setDestCode(String destCode) {
        this.destCode = destCode;
    }

    @XmlElement
    public boolean isActive() {
        return isActive;
    }

    public void setActive(boolean isActive) {
        this.isActive = isActive;
    }

}
